package com.episode.duetapi.utils;

import java.util.Random;

public class RandomUtil {


    public static String random4() {
        String code = String.valueOf((int) ((Math.random() * 9 + 1) * 1000));
        return code;
    }

    public static String getRandomCharAndNumr(Integer length) {
        String str = "";
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            boolean b = random.nextBoolean();
            if (b) { // 字符串
                // int choice = random.nextBoolean() ? 65 : 97; 取得65大写字母还是97小写字母
                str += (char) (65 + random.nextInt(26));// 取得大写字母
            } else { // 数字
                str += String.valueOf(random.nextInt(10));
            }
        }
        return str;
    }

    public static String getRandNumber(String number) {
        int x = Integer.valueOf(number) - 5 + 1;
        int result = new Random().nextInt(x) + 5;
        return String.valueOf(result);
    }
}
